Skip to content

Method: VierGewinntPlayerImpl(VierGewinntState, String, boolean)

1: package de.fhdw.gaming.ipspiel21.viergewinnt.core.domain.impl;
2:
3: import java.util.Optional;
4:
5: import de.fhdw.gaming.core.domain.PlayerState;
6: import de.fhdw.gaming.ipspiel21.viergewinnt.core.domain.VierGewinntFieldState;
7: import de.fhdw.gaming.ipspiel21.viergewinnt.core.domain.VierGewinntPlayer;
8: import de.fhdw.gaming.ipspiel21.viergewinnt.core.domain.VierGewinntState;
9:
10: /**
11: * The Implementation of a VierGewinntPlayer.
12: *
13: * @author Robby Rabbitman
14: *
15: */
16: public class VierGewinntPlayerImpl implements VierGewinntPlayer {
17:
18: /**
19: * The associated game state.
20: */
21: private final VierGewinntState gameState;
22:
23: /**
24: * The name of this player.
25: */
26: private final String name;
27:
28: /**
29: * true if yellow.
30: *
31: */
32: private final boolean usingYellow;
33:
34: /**
35: * The Constructor.
36: *
37: * @param gameState
38: * @param name
39: * @param usingYellow
40: */
41: public VierGewinntPlayerImpl(final VierGewinntState gameState, final String name, final boolean usingYellow) {
42: super();
43: this.gameState = gameState;
44: this.name = name;
45: this.usingYellow = usingYellow;
46:
47: }
48:
49: @Override
50: public String getName() {
51: return this.name;
52: }
53:
54: @Override
55: public PlayerState getState() {
56: return this.gameState.getPlayerState(this.getName());
57: }
58:
59: @Override
60: public Optional<Double> getOutcome() {
61: return this.gameState.getPlayerOutcome(this.getName());
62: }
63:
64: @Override
65: public boolean isUsingYellow() {
66: return this.usingYellow;
67: }
68:
69: @Override
70: public VierGewinntFieldState getPlayerMark() {
71: if (this.isUsingYellow()) {
72: return VierGewinntFieldState.YELLOW;
73: } else {
74: return VierGewinntFieldState.RED;
75: }
76: }
77:
78: @Override
79: public VierGewinntPlayer deepCopy(final VierGewinntState newGameState) {
80: return new VierGewinntPlayerImpl(newGameState, this.name, this.isUsingYellow());
81: }
82:
83: }